package models;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Created by yangxianming on 2018/12/14.
 * getBody：读取body数据
 */
public class Request {
    public static String getBody(HttpServletRequest request) throws Exception{
        //读取请求json
        InputStreamReader inputStreamReader;
        BufferedReader bufferedReader;
        String requestInfo = "";

        inputStreamReader = new InputStreamReader(request.getInputStream(), "UTF-8");
        bufferedReader = new BufferedReader(inputStreamReader);
        String line;
        while ((line = bufferedReader.readLine()) != null)
            requestInfo = requestInfo + line;
        return requestInfo;
    }
}
